package com.example.fz338.ui.home;

import android.util.Log;

import com.example.fz338.bean.NewsBean;
import com.example.fz338.utils.NetUtils;
import com.github.leonardoxh.livedatacalladapter.Resource;

import java.util.List;

import androidx.lifecycle.LiveData;
import androidx.lifecycle.Transformations;
import androidx.lifecycle.ViewModel;


public class HomeViewModel extends ViewModel {

    public LiveData<List<NewsBean>> getNewsList() {
        // 数据转换 这里是 Resource 转 List
        return Transformations.map(NetUtils.get().getNewsList(), Resource::getResource);
    }

    public LiveData<List<NewsBean>> getAdList() {
        return Transformations.map(NetUtils.get().getAdList(), Resource::getResource);
    }

}